import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

/**
 * Simple servlet for testing deployment on server.
 * <p>
 * From <a href="http://courses.coreservlets.com/Course-Materials/">the
 * coreservlets.com tutorials on servlets, JSP, Struts, JSF, Ajax, GWT, Spring,
 * Hibernate/JPA, and Java programming</a>.
 */

public class Start extends HttpServlet {
  @Override
  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

	  String parent = (String)request.getParameter("comments");
	  String appinion = (String)request.getParameter("appinion");
	  String moderator = (String)request.getParameter("moderator");
	  QueryProcess.clean();
	  
	  QueryProcess.getInstance().initialize(parent, appinion, moderator);
      
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    String docType = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 "
        + "Transitional//EN\">\n";
    out.println(docType
        + "<HTML>\n"
        + "<HEAD><TITLE>Statistics</TITLE>"
        + "<style type=\"text/css\">"
        + "body{margin-top:5%;margin-left:20%;margin-right:20%;background-color:#696969;background-repeat:no-repeat;}"
        + ".container{text-align:center;}"

        + ".center_div { border:1px gray; margin-left:10%; margin-right:10%; background-color:white; text-align:center; padding:8px; }</style>"
        + "</HEAD>\n"
        + "<div class=\"container\">"
        + " <div class=\"center_div\">"
        + "<h1>Statistics </h1>"
        +

        "<form method=GET action=\"hi\">"
        + "<input type=submit style=\"height: 50px; width: 300px\" name=cmd value=Opinion>"
        + "<input type=\"hidden\" name=\"id\" value=\"opinionstat\">"
        + " </form> "
        +

        "<form method=GET action=\"hi\">"
        + "<input type=submit style=\"height: 50px; width: 300px\" name=cmd value=Comment>"
        + "<input type=\"hidden\" name=\"id\" value=\"commentstat\">"
        + " </form> "
        +

        "<form method=GET action=\"hi\">"
        + "<input type=submit style=\"height: 50px; width: 300px\" name=cmd value=Moderator>"
        + "<input type=\"hidden\" name=\"id\" value=\"moderatorstat\">"
        + " </form> "
        +

        "<form method=GET action=\"hi\">"
        + "<input type=submit style=\"height: 50px; width: 300px\" name=cmd value=Issue>"
        + "<input type=\"hidden\" name=\"id\" value=\"issuestat\">"
        + " </form> "
        +

        "<form method=GET action=\"hi\">"
        + "<input type=submit style=\"height: 50px; width: 300px\" name=cmd value=Author >"
        + "<input type=\"hidden\" name=\"id\" value=\"authorstat\">"
        + " </form> "
        +

        "<form method=GET action=\"hi\">"
        + "<input type=submit style=\"height: 50px; width: 300px\" name=cmd value=\"Opinion Holder\">"
        + "<input type=\"hidden\" name=\"id\" value=\"opinionhold\">"

        + " </form> " + "</div></div>" + "</BODY></HTML>");
  }
}
